package com.hue.concurrent.day04;

/*
    活锁:
        两个线程对同一个资源操作，导致两个线程永远执行不完
 */
public class Demo05 {
    private static int count = 10;
    public static void main(String[] args) {
        new Thread(() -> {
            while (count > 0){
                try {
                    Thread.sleep(200);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                count--;
            }
        }).start();

        new Thread(() -> {
            while (count < 20){
                try {
                    Thread.sleep(200);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                count++;
            }
        }).start();
    }
}
